﻿using System;
using System.Web.UI;

namespace ReadyApps.Wiki
{
    class WikiControlSettings
    {
        #region Properties

        public string CKEditorBasePath { get; set; }

        public ITemplate LayoutTemplate { get; set; }
        public ITemplate EditLayoutTemplate { get; set; }
        public ITemplate PageNotFoundTemplate { get; set; }
        public ITemplate PageNotAuthorizedTemplate { get; set; }
        public ITemplate ButtonTemplate { get; set; }

        #endregion

        #region Status Change Event

        private event EventHandler<WikiPageStatusEventArgs> statusChange;

        public event EventHandler<WikiPageStatusEventArgs> StatusChange
        {
            add { statusChange += value; }
            remove { statusChange -= value; }
        }

        public void OnStatusChange(object sender, WikiPageStatusEventArgs e)
        {
            if (statusChange != null)
            {
                statusChange(sender, e);
            }
        }

        #endregion

        #region Include Resource Event

        private event EventHandler<IncludeResourceEventArgs> includeResource;

        public event EventHandler<IncludeResourceEventArgs> IncludeResource
        {
            add { includeResource += value; }
            remove { includeResource -= value; }
        }

        public void OnIncludeResource(object sender, IncludeResourceEventArgs e)
        {
            if (includeResource != null)
            {
                includeResource(sender, e);
            }
        }

        #endregion

        #region Title Set Event

        private event EventHandler<TitleSetEventArgs> titleSet;

        public event EventHandler<TitleSetEventArgs> TitleSet
        {
            add { titleSet += value; }
            remove { titleSet -= value; }
        }

        public void OnTitleSet(object sender, TitleSetEventArgs e)
        {
            if (titleSet != null)
            {
                titleSet(sender, e);
            }
        }

        #endregion

        #region Redirect Event

        private event EventHandler<RedirectEventArgs> redirect;

        public event EventHandler<RedirectEventArgs> Redirect
        {
            add { redirect += value; }
            remove { redirect -= value; }
        }

        public void RequestRedirect(string url)
        {
            if (redirect != null)
            {
                redirect(null, new RedirectEventArgs(url));
            }
        }

        #endregion
    }
}
